List of scripts to be run for replication of analysis and create figures for the main manuscript and Appendix. All analysis was completed using R 3.6


Run scripts in order listed as some scripts create objects needed by subsequent scripts. Models will not perfectly replicate due to error when the RNG state is passed between R and the backend C code. To show that the small changes for estimates in each run do not change the substantive conclusions in this paper, we include two sets of results. For every script that is run, there is a *.Rout log file. Note that if running the models with PBS scripts, the R scripts for the ERGM models have been named so that the same PBS scripts will work in each sub-folder.

1. packages.R - installs needed packages, including the ergm package from source that includes user-added terms.
2. ergm_3.10.4.tar.gz - ergm package with user-added terms
3. manuscript_results - includes manuscripts with results from ERGM_Count_Models_RUN*
 					

ERGM_Count_Models_RUN*/
1. main/
	Scripts:
	a. ergm_*.R - Runs main models
	b. ModelFitComparison.R - Figure 1
	c. run_simulations.R - run simulations for Figure 2
	d. gof_plots.R - Figure 2  
	e. ModelInterpretation.R - Figure 4
	f. CovariateInterpretation.R - Figure 8
	g. contagion_simulation.R - simulate contagion networks for plot in Figure 9
	h. contagion_interpretation.R - Figure 9
	Data Files:
	a. *_network_results_RR.RData - ERGM results with network covariates
	b. *_independent_results_RR.RData - ERGM results without network covariates
	c. main_net.Rdata - network objects
	d. main_cov.Rdata - edgecovariates
	e. interpretationStats.RData - from ModelInterpretation.R
	f. network_independent_sims.RData - from run_simulations.R
	g. network_result_sims.RData - from run_simulations.R
	h. recip_sims.RData - from gof_plots.R
	i. contagion_simulation.csv - from contagion_simulation.R
	j. sim_dist_net.RData - from contagion_simulation.R
	k. sim_dist_net_neg.RData - from contagion_simulation.R
	l. simulatedNetworks.RData - from ModelInterpretation.R
	m. simulatedNetworksIndependent.RData - from ModelInterpretation.R
	n. trans_sim.RData - from gof_plots.R
	figures/ - includes all figures in manuscript that are not rope-ladder plots
2. Descriptive/
	Scripts:
	a. impute_values.R - impute values using Amelia package to compare distribtions
	b. SI_sectionA.R - Section A in Appendix
	c. edge_distribution_comparison - Section B in Appendix
	d. correlation_function.R - function used in SI_sectionA.R
	Data:
	a. MI_data.Rdata - from impute_values.R
	b. FDI_stock_data.csv - raw FDI stock data
	c. FDI_stock_panel_data.csv - FDI stock data as panel with covariates
	descriptive_plots/ - non-rope-ladder plots from Appendix
3. TERGM/_
	Scripts:
	a. stage2_prep.R - Preps data using results from the main models
	b. ergm_*.R - Runs the second stage of time pooled ERGMS
	c. pool_results.R - pools results from second stage
	Data Files:
	a. *_pooled_results_RR.RData - ERGM results with network covariates
	b. pooledERGM.Rdata - from pool_results.R
	c. main_cov.Rdata - network objects
	d. main_net.Rdata - edgecovariates
	e. SE.Rdata - from stage2_prep.R
	f. pooled_par.Rdata - from stage2_prep.R
4. Omit_tax_havens/ - models with tax rates and without tax havens
	Scripts:
	a. ergm_*.R - runs models
	Data Files:
	a. *_haven_network_results_RR.RData - ERGM results with network covariates
	b. haven_cov.Rdata - network objects
	c. haven_net.Rdata - edgecovariates	
5. Omit_EU/
	Scripts:
	a. ergm_*.R - runs models
	Data Files:
	a. *_EU_network_results_RR.RData - ERGM results with network covariates
	b. EU_cov.Rdata - network objects
	c. EU_net.Rdata - edgecovariates	
6. Omit_Missing_Values/
	Scripts:
	a. q25/ergm_*.R - runs models
	b. q50/ergm_*.R - runs models
	Data Files:
	a. q25/*_q25_network_results_RR.RData - ERGM results with network covariates
	b. q25/q25_cov.Rdata - network objects
	c. q25/q25_net.Rdata - edgecovariates
	d. q50/*_q50_network_results_RR.RData - ERGM results with network covariates
	e. q50/q50_cov.Rdata - network objects
	f. q50/q50_net.Rdata - edgecovariates	
7. AMEN/
	Scripts:
	a. run_amen.R - runs models
	Data Files:
	a. amen_results_RR.RData - model
	b. main_cov.Rdata - network objects
	c. main_net.Rdata - edgecovariates
	d. Rplots.pdf - produced by amen package, but because models are parallelized the file 				becomes damaged. Run models serially to create/view.
8. Include_tax/ (Models may not converge after 100 iterations due to multicollinerity, but estimates are stable by then.)
	Scripts:
	a. run_amen.R - runs models
	Data Files:
	a. *_tax_network_results_RR.RData - ERGM results with network covariates
	b. tax_cov.Rdata - network objects
	c. tax_net.Rdata - edgecovariates
9. Include_xr/ (Models may not converge after 100 iterations due to multicollinerity, but estimates are stable by then.)
	Scripts:
	a. run_amen.R - runs models
	Data Files:
	a. *_xr_network_results_RR.RData - ERGM results with network covariates
	b. xr_cov.Rdata - network objects
	c. xr_net.Rdata - edgecovariates
10. rl_plots/ - all rope-ladder coefficient plots
	Scripts:
	a. main_rl_plots.R - creates rope ladder plots for Figure 3, 5, 6, 7
	b. TERGM_rl_plots.R - creates rope ladder plots for all variables
	c. haven_rl_plots.R - creates rope ladder plots for all variables
	d. EU_rl_plots.R - creates rope ladder plots for all variables
	e. q_rl_plots.R - creates rope ladder plots for all variables
	f. amen_rl_plots.R - creates rope ladder plots for all variables
	g. tax_rl_plots.R - creates rope ladder plots for all variables
	h. xr_rl_plots.R - creates rope ladder plots for all variables
	Data Files:
	a. main_rl_plots/ - rope ladder plots for Figure 3, 5, 6, 7
	b. TERGM_rl_plots/ - rope ladder plots for all variables
	c. haven_rl_plots/ - rope ladder plots for all variables
	d. EU_rl_plots/ - rope ladder plots for all variables
	e. q_rl_plots/ - rope ladder plots for all variables
	f. amen_rl_plots/ - rope ladder plots for all variables
	g. tax_rl_plots/ - rope ladder plots for all variables
	h. xr_rl_plots/ - rope ladder plots for all variables


